﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;
using NW;

namespace OSM
{
	internal delegate void OSMClientEvent(OSMClient C);
	internal delegate void OSMClientEventS(OSMClient C, String S);
	internal class OSMServer : NWServer
	{
		internal event OSMClientEvent OnLoad;
		internal event OSMClientEvent OnReset;

		internal OSMServer(int port)
			: base(port)
		{
			ClientExit += (s, c) =>
			{
				Console.WriteLine("Client exiting");
			};
			ClientListEmpty += s =>
			{
			};
		}
		protected override NWClient MakeClient(TcpClient C)
		{
			OSMClient Res = new OSMClient(C);
			Res.OnData += NWClient.DataHash;
			Res.OnData += new NWClientDataEvent(Res_OnData);
			Res.OnLoad += OnLoad;
			Res.OnReset += OnReset;
			return Res;
		}

		void Res_OnData(NWClient sender, byte[] data)
		{
			sender.SendPacket(1, 3, 5, 7, "ABCD");
		}
	}
	internal class OSMClient : NWClient
	{
		internal event OSMClientEvent OnLoad;
		internal event OSMClientEvent OnReset;
		internal OSMClient(TcpClient C)
			: base(C)
		{
		}
		protected override bool _ProcessMessage()
		{
			return true;
		}
	}
}